<template>
	<view class="content">
		<view class="header">
			<view class="ipt-box">
				<input v-model="number" type="text" value="" placeholder="请输入预约编号" placeholder-class="plac-class" />
				<image src="../../static/search1.png" mode="" @click="searchList"></image>
			</view>
			<view class="header-right">
				<easy-select class="easySelect" style="width:360rpx;height:100%;font-size: 28rpx;color: #fff;"
					:options="options" ref="easySelect" size="medium" :value="selecValue" @selectOne="selectOne">
				</easy-select>
				<!-- <span @click="trackFlag = !trackFlag">{{trackName}}</span>
				<image src="../../../static/xiala.png" mode=""></image>
				<view class="genFle" v-if="trackFlag">
					<view v-for="(item,index) in trackList" :key="index" class="" @click="track(item)">{{item}}</view>
				</view> -->
			</view>
		</view>
		<!-- nav -->
		<!-- <view class="nav">
			<view class="nav-box">
				<span :class="{'current' :active===1}" @click="navClick(0)">我上传的隐患</span>
				<span :class="{'current' :active===2}" @click="navClick(1)">所有隐患</span>
			</view>
		</view> -->
		<!-- danger -->
		<view class="danger-box">
			<view class="danger-item" v-for="(item,index) in dangerList" :key="index" @tap="checkDanger(item.id)">
				<view class="safe">
					<image src="/static/aqy.png" mode=""></image>用户：{{item.realname}}
				</view>
				<view>预约编号：{{item.no}}</view>
				<view>预约日期：{{item.time}}</view>
				<view>预约事项：{{item.category_name}}</view>
				<view @tap.stop="call(item.mobile)">电<text class="kong"></text>话：{{item.mobile}}</view>
				<view>地<text class="kong"></text>址：{{item.address}}</view>
				<view>身份证号：{{item.ID_num}}</view>
				<view>状<text class="kong"></text>态：
					<template v-if="item.check_status ==0">
						未处理
					</template>
					<template v-if="item.check_status ==1">
						待审核
					</template>
					<template v-if="item.check_status ==2">
						通过
					</template>
					<template v-if="item.check_status ==3">
						驳回
					</template>
				</view>
				<view v-if="item.reason&&item.check_status ==3">驳回原因：{{item.reason || ''}}</view>
				<text class="chaoshi_zhuantai">{{item.check_status !=2 && item.exceed_time == false ? '' : '已超时'}}</text>
				<!-- <image class="shenhe" :src="item.status_picture" mode=""></image> -->
			</view>
			<view class="nomodel" v-if="dangerList.length==0">
				<u-empty text="暂无预约工单" mode="list"></u-empty>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: '',
				password: '',
				// array: ['安装工','检测工','维修工'],
				index: 0,
				userinfo: {},
				value: '', //搜索关键词
				installList: [], //安装列表
				dosearch: false,
				showAcount: false,
				page: 1,
				dangerList: [],
				active: 1,
				trackFlag: false,
				trackName: 2,
				selecValue: '未处理',
				options: [{
						id: 2,
						label: '未处理'
					},
					{
						id: 1,
						label: '已处理'
					},
					{
						id: 4,
						label: '驳回'
					},
					{
						id: 3,
						label: '全部'
					}
				],
				number: '',
				totwn: ''
			};
		},
		onShow() {
			this.dangerList = []
			this.getInstallDetail()
		},
		onLoad() {

		},
		//下拉刷新
		onPullDownRefresh() {
			this.page = 1
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 500);
			this.getInstallDetail()
		},
		onReachBottom() {
			if (this.page >= this.totwn) {
				uni.showToast({
					title: '没有更多数据',
					icon: 'none'
				})
				return
			} else {
				this.page++
				this.getInstallDetail()
			}

		},
		methods: {
			call(num) {
				uni.makePhoneCall({
					phoneNumber: num
				})
			},
			selectOne(option) {
				this.dangerList = []
				this.selecValue = option.label
				this.trackName = option.id
				this.getInstallDetail()
			},
			checkDanger(id) {
				uni.navigateTo({
					url: './detail?id=' + id
				})
			},
			navClick(i) {
				this.page = 1
				this.dangerList = []
				this.active = i + 1
				this.getInstallDetail()
			},
			searchList() {
				this.page = 1
				this.dangerList = []
				this.getInstallDetail()
			},

			// 获取安装数据
			getInstallDetail() {
				let that = this
				// uni.showLoading({uni.hideLoading()
				// 	title:'查询中'
				// })
				uni.request({
					url: this.$api + 'staff/getYuyueLists',
					method: 'POST',
					header: {
						token: uni.getStorageSync('token'),
						'content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						page: that.page,
						no: that.number,
						isdone: that.trackName
					},
					success: (res) => {
						console.log('page', that.page);
						console.log('no',that.number);
						console.log('isdone', that.trackName);
						if (res.data.code == 1) {
							that.totwn = res.data.data.page_count
							that.dangerList = that.dangerList.concat(res.data.data)
						} else {
							that.$showToast(res.data.msg)
							that.number = ''
						}
					}
				})
			},
		},

	}
</script>

<style lang="scss" scoped>
	.content {
		padding-bottom: 140rpx;
		background: #F1F1F1;
		min-height: 100vh;
	}

	.header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		height: 80rpx;
		width: 100%;
		background-color: #003690;
		padding: 0 40rpx;

		.ipt-box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			padding: 0 20rpx;
			width: 514rpx;
			height: 52rpx;
			background-color: #fff;
			border-radius: 28rpx;

			input {
				width: 85%;
			}

			image {
				width: 32rpx;
				height: 32rpx;
			}
		}

		.header-right {
			display: flex;
			align-items: center;
			font-size: 32rpx;
			color: #E2ECFB;
			position: relative;

			image {
				width: 36rpx;
				height: 36rpx;
			}

			.genFle {
				position: absolute;
				top: 64rpx;
				left: 0;
				width: 100%;
				background-color: #fff;
				border: 2rpx solid #ccc;
				color: #003690;
				text-align: center;
				z-index: 999;

				view {
					border-bottom: 2rpx solid #ccc;
					line-height: 60rpx;
				}
			}
		}
	}

	.test-code:active {
		background: rgba(69, 82, 202, 0.4);
		color: #fff;
	}

	.plac-class {
		font-size: 32rpx;
		color: #999;
	}

	// nav
	.nav {
		width: 100%;
		height: 80rpx;
		background-color: #fff;

		.nav-box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 100%;
			margin: 0 auto;
			line-height: 76rpx;
			background: #FFFFFF;
			justify-content: space-evenly;

			span {
				padding: 0 10rpx;
				font-size: 32rpx;
				color: #333;
				border-bottom: 4rpx solid transparent;
			}

			.current {
				color: #003690;
				border-bottom: 4rpx solid #003690;
			}
		}
	}

	// danger
	.danger-item {
		position: relative;
		box-sizing: border-box;
		width: 690rpx;
		padding: 30rpx;
		background-color: #fff;
		border-radius: 10rpx;
		margin: 30rpx auto 0;
		box-shadow: 0px 3px 4px rgba(0, 30, 57, 0.15);

		view {
			margin-top: 10rpx;
		}

		.safe {
			color: #003690;
			font-size: 28rpx;
			line-height: 38rpx;

			image {
				width: 36rpx;
				height: 36rpx;
				margin-right: 6rpx;
				vertical-align: bottom;
			}
		}

		.kong {
			display: inline-block;
			width: 56rpx;
		}

		.kong1 {
			display: inline-block;
			width: 14rpx;
		}

		.chaoshi_zhuantai {
			position: absolute;
			top: 20rpx;
			right: 20rpx;
			color: red;
			font-size: 28rpx;
			line-height: 38rpx;
		}

		.shenhe {
			position: absolute;
			top: 100rpx;
			right: 20rpx;
			width: 170rpx;
			height: 170rpx;
		}
	}
</style>
